package com.zzh.takeoutapp.adapter;

import android.content.Context;
import android.support.annotation.Nullable;
import android.support.v7.widget.GridLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.RatingBar;
import android.widget.TextView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.zzh.takeoutapp.R;
import com.zzh.takeoutapp.adapter.order.more.RvListener;
import com.zzh.takeoutapp.base.MyBaseAdapter;
import com.zzh.takeoutapp.model.EvaluateBean;
import com.zzh.takeoutapp.utils.ImageManager;
import com.zzh.takeoutapp.view.folw.FlowTagLayout;

import java.util.ArrayList;
import java.util.List;

import butterknife.Bind;
import butterknife.ButterKnife;

/**
 * Created by Administrator on 2018/7/30.
 */

public class CommentAdapter extends BaseQuickAdapter<EvaluateBean.DataBean.ItemsBean, BaseViewHolder> {
    private MerchantAdapter merchantAdapter;

    public CommentAdapter(@Nullable List<EvaluateBean.DataBean.ItemsBean> data) {
        super(R.layout.item_evaluate_list, data);
    }

    @Override
    protected void convert(BaseViewHolder holder, EvaluateBean.DataBean.ItemsBean itemsBean) {

        ImageManager.loadCircleImage(mContext, itemsBean.getFace(), ((ImageView) holder.getView(R.id.user_head)));
        ((TextView) holder.getView(R.id.tv_content)).setText(itemsBean.getContent());
        ((TextView) holder.getView(R.id.tv_reply_time)).setText(itemsBean.getDateline());
        ((TextView) holder.getView(R.id.tv_nickname)).setText(itemsBean.getUsername());
        ((TextView) holder.getView(R.id.tv_pei_time)).setText("专送" + itemsBean.getPei_time());
        //   ((TextView) holder.getView(R.id.tv_avg_score)).setText("口味:" + detailBeans.getAvg_peisong());
        ((TextView) holder.getView(R.id.tv_package)).setText("包装:" + itemsBean.getScore());
        // ((TextView) holder.getView(R.id.tv_avg_peisong)).setText("配送:" + detailBeans.getAvg_peisong());
        ((RatingBar) holder.getView(R.id.rb_score)).setRating(Float.parseFloat(itemsBean.getScore()));
        List<String> list = new ArrayList<>();
        List<EvaluateBean.DataBean.ItemsBean.CommentPhotosBean> comment_photos = itemsBean.getComment_photos();
        if (itemsBean.getComment_photos() != null) {
            for (int i = 0; i < comment_photos.size(); i++) {
                list.add(comment_photos.get(i).getPhoto());
            }
            merchantAdapter = new MerchantAdapter(mContext, list, new RvListener() {
                @Override
                public void onItemClick(int id, int position) {
                }
            });
            ((RecyclerView) holder.getView(R.id.recyclerView)).
                    setLayoutManager(new GridLayoutManager(mContext, 3));
            ((RecyclerView) holder.getView(R.id.recyclerView)).setAdapter(merchantAdapter);
        }
    }
}
